package com.woniuxy.jwt;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;

/**
 * @Author: 马宇航
 * @Todo: 解析jwt字符串 Authorization
 * @DateTime: 22/02/22/0022 下午 3:40
 * @Component: 成都蜗牛学苑
 **/
public class ParseJwt {
    public static void main(String[] args) {
        String token="eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI4ODgiLCJzdWIiOiJhZG1pbiIsImlhdCI6MTY0NTUxNjEwMCwiZXhwIjoxNjQ1NTE2MTU5LCJ1c2VybmFtZSI6Im1heXVoYW5nIiwicGFzc3dvcmQiOjEyMzQ1Nn0.KpkMoxeZsyYrqw4K9XWVWcGqCb5Inu8WHTMavW5sbbI";
        Claims claims = Jwts.parser().setSigningKey("woniuxy").parseClaimsJws(token).getBody();
        System.out.println(claims.getId());
        System.out.println(claims.getSubject());
        System.out.println(claims.getIssuedAt());
        System.out.println(claims.get("username"));
        System.out.println(claims.get("password"));
    }
}
